import App from '../App'

const customer = r => require.ensure([], () => r(require('../page/customer/customer')), 'customer')
const customerDetail = r => require.ensure([], () => r(require('../page/customer/children/customerDetail')), 'customerDetail')
const customerSearch = r => require.ensure([], () => r(require('../page/customer/children/customerSearch')), 'customerSearch')
const schedule = r => require.ensure([], () => r(require('../page/schedule/schedule')), 'schedule')
const startPicking = r => require.ensure([], () => r(require('../page/schedule/children/startPicking')), 'startPicking')
const warehouse = r => require.ensure([], () => r(require('../page/warehouse/warehouse')), 'warehouse')
const category = r => require.ensure([], () => r(require('../page/category/category')), 'category')
const position = r => require.ensure([], () => r(require('../page/position/position')), 'position')
const goodsDetail = r => require.ensure([], () => r(require('../page/goodsDetail/goodsDetail')), 'goodsDetail')
const login = r => require.ensure([], () => r(require('../page/login/login')), 'login')
const profile = r => require.ensure([], () => r(require('../page/profile/profile')), 'profile')
const forget = r => require.ensure([], () => r(require('../page/forget/forget')), 'forget')
const inorderDetail = r => require.ensure([], () => r(require('../page/inorder/inorderDetail')), 'inorderDetail')
const confirmOrder = r => require.ensure([], () => r(require('../page/confirmOrder/confirmOrder')), 'confirmOrder')
const payment = r => require.ensure([], () => r(require('../page/confirmOrder/payment')), 'payment')
const info = r => require.ensure([], () => r(require('../page/profile/children/info')), 'info')
const address = r => require.ensure([], () => r(require('../page/profile/children/children/address')), 'address')
const add = r => require.ensure([], () => r(require('../page/profile/children/children/children/add')), 'add')
const modifyPassword = r => require.ensure([], () => r(require('../page/profile/children/children/modifyPassword')), 'modifyPassword')
const modifyPayPassword = r => require.ensure([], () => r(require('../page/profile/children/children/modifyPayPassword')), 'modifyPayPassword')
const addDetail = r => require.ensure([], () => r(require('../page/profile/children/children/children/children/addDetail')), 'addDetail')
const balance = r => require.ensure([], () => r(require('../page/balance/balance')), 'balance')
const balanceDetail = r => require.ensure([], () => r(require('../page/balance/children/detail')), 'balanceDetail')
const recharge = r => require.ensure([], () => r(require('../page/balance/children/recharge')), 'recharge')
const rechargeSuccess = r => require.ensure([], () => r(require('../page/balance/children/children/rechargeSuccess')), 'rechargeSuccess')
const regist = r => require.ensure([], () => r(require('../page/regist/regist')), 'regist')
const registSuccess = r => require.ensure([], () => r(require('../page/regist/children/registSuccess')), 'registSuccess')
const registProtocol = r => require.ensure([], () => r(require('../page/regist/children/registProtocol')), 'registProtocol')
const confirmPassword = r => require.ensure([], () => r(require('../page/forget/children/confirmPassword')), 'confirmPassword')
const integralMall = r => require.ensure([], () => r(require('../page/integralMall/integralMall')), 'integralMall')
const integralRecord = r => require.ensure([], () => r(require('../page/integralMall/integralRecord')), 'integralRecord')
const conversionRecord = r => require.ensure([], () => r(require('../page/integralMall/conversionRecord')), 'conversionRecord')
const howGetJiubi = r => require.ensure([], () => r(require('../page/integralMall/children/howGetJiubi')), 'howGetJiubi')
const myCoupons = r => require.ensure([], () => r(require('../page/myCoupons/myCoupons')), 'myCoupons')
const couponsDetail = r => require.ensure([], () => r(require('../page/myCoupons/children/couponsDetail')), 'couponsDetail')
const offenList = r => require.ensure([], () => r(require('../page/goodsList/offenList')), 'offenList')
const goodsList = r => require.ensure([], () => r(require('../page/goodsList/goodsList')), 'goodsList')
const achievement = r => require.ensure([], () => r(require('../page/profile/children/achievement')), 'achievement')
const statistics = r => require.ensure([], () => r(require('../page/profile/children/statistics')), 'statistics')
const saleStatistics = r => require.ensure([], () => r(require('../page/profile/children/children/saleStatistics')), 'saleStatistics')
const warehouseStatistics = r => require.ensure([], () => r(require('../page/profile/children/children/warehouseStatistics')), 'warehouseStatistics')
const goodsStatistics = r => require.ensure([], () => r(require('../page/profile/children/children/goodsStatistics')), 'goodsStatistics')
const cateDetails = r => require.ensure([], () => r(require('../page/profile/children/children/children/cateDetails')), 'cateDetails')
const choseTime = r => require.ensure([], () => r(require('../page/profile/children/children/children/choseTime')), 'choseTime')
const customerStatistics = r => require.ensure([], () => r(require('../page/profile/children/children/customerStatistics')), 'customerStatistics')
const order = r => require.ensure([], () => r(require('../page/order/order')), 'order')
const orderDetail = r => require.ensure([], () => r(require('../page/order/children/orderDetail')), 'orderDetail')
const logistics = r => require.ensure([], () => r(require('../page/logistics/logistics')), 'logistics')
const myMessages = r => require.ensure([], () => r(require('../page/profile/children/myMessages')), 'myMessages')
const newMechanisms = r => require.ensure([], () => r(require('../page/profile/children/children/newMechanisms')), 'newMechanisms')
const receiveVoucher = r => require.ensure([], () => r(require('../page/profile/children/children/receiveVoucher')), 'receiveVoucher')
const showValidate = r => require.ensure([], () => r(require('../page/voucher/showValidate')), 'showValidate')
const voucherDetail = r => require.ensure([], () => r(require('../page/voucher/voucherDetail')), 'voucher')
const voucherSellers = r => require.ensure([], () => r(require('../page/voucher/voucherSellers')), 'getReceiveVoucherSellers')
const myAdmissionTicket = r => require.ensure([], () => r(require('../page/wallet/myAdmissionTicket')), 'myAdmissionTicket')
const ticketAdministration = r => require.ensure([], () => r(require('../page/ticketAdministration/ticketAdministration')), 'ticketAdministration')
const exchangeCode = r => require.ensure([], () => r(require('../page/ticketAdministration/exchangeCode')), 'exchangeCode')

const setPayPwd = r => require.ensure([], () => r(require('../page/confirmOrder/children/setPayPwd')), 'setPayPwd')
const confirmPayPwd = r => require.ensure([], () => r(require('../page/confirmOrder/children/children/confirmPayPwd')), 'confirmPayPwd')
const paySuccess = r => require.ensure([], () => r(require('../page/confirmOrder/children/paySuccess')), 'paySuccess')

export default [{
  path: '/',
  component: App, //顶层路由，对应index.html
  children: [ //二级路由。对应App.vue
    //地址为空时跳转login页面
    {
      path: '',
      redirect: '/login'
    },
    //客户
    {
      path: '/customer',
      component: customer,
      meta: {
        title: '客户',
        requiresAuth: true,
        keepAlive: true
      },
      children: [{
        path: 'customerDetail', //门店简介
        component: customerDetail,
        meta: {
          title: '门店简介'
        }
      }, {
        path: 'customerSearch', //门店搜索
        component: customerSearch,
        meta: {
          title: '门店搜索'
        }
      }]
    },
    //常购清单 --下拉
    {
      path: '/offenList',
      component: offenList,
      meta: {
        title: '常购清单',
        requiresAuth: true
      }
    },
    //批货管理
    {
      path: '/category',
      component: category,
      meta: {
        title: '批货管理',
        requiresAuth: true
      }
    },
    //岗位管理
    {
      path: '/position',
      component: position,
      meta: {
        title: '岗位管理',
        requiresAuth: true
      }
    },
    //物流
    {
      path: '/logistics',
      component: logistics,
      meta: {
        title: '物流',
        requiresAuth: true
      }
    },
    //注册
    {
      path: '/regist',
      component: regist,
      meta: {
        title: '注册'
      },
      children: [{
        path: 'registSuccess', //注册成功页
        component: registSuccess,
        meta: {
          title: '注册成功'
        }
      }, {
        path: 'registProtocol', //注册协议页
        component: registProtocol,
        meta: {
          title: '注册协议'
        }
      }]
    },
    //仓库页
    {
      path: '/warehouse',
      component: warehouse,
      meta: {
        title: '仓库',
        requiresAuth: true,
        keepAlive: true
      }
    },
    //热销商品列表页和新品推荐列表页
    {
      path: '/goodsList',
      component: goodsList,
      meta: {
        title: '商品列表',
        requiresAuth: true
      }
    },
    //理货页
    {
      path: '/schedule',
      component: schedule,
      meta: {
        title: '理货',
        requiresAuth: true,
        keepAlive: true
      },
      children: [{
        path: 'startPicking', //开始配货页面
        component: startPicking,
        name: 'startPicking',
        meta: {
          title: '开始配货',
          requiresAuth: true
        }
      }]
    },
    //商品详情页
    {
      path: '/goodsDetail',
      component: goodsDetail,
      meta: {
        title: '商品详情',
        requiresAuth: true
      }
    },
    //支付方式选择页面
    {
      path: '/payment',
      name: 'payment',
      component: payment,
      meta: {
        title: '支付方式选择',
        requiresAuth: true
      },
      children: [{
        path: 'paySuccess', //支付结果页面
        component: paySuccess,
        name: 'paySuccess',
        meta: {
          title: '支付结果',
          requiresAuth: true
        }
      }, {
        path: 'setPayPwd',
        component: setPayPwd,
        name: 'setPayPwd',
        meta: {
          title: '设置支付密码',
          requiresAuth: true
        },
        children: [{
          path: 'confirmPayPwd', //设置支付密码
          name: 'confirmPayPwd',
          component: confirmPayPwd,
          meta: {
            title: '设置支付密码',
            requiresAuth: true
          }
        }]
      }, {
        path: 'forgetPayPwd',
        component: setPayPwd,
        name: 'forgetPayPwd',
        meta: {
          title: '找回支付密码',
          requiresAuth: true,
          type: 'forget'
        },
        children: [{
          path: 'modifyPayPwd', //支付密码页
          name: 'modifyPayPwd',
          component: confirmPayPwd,
          meta: {
            title: '找回支付密码',
            requiresAuth: true
          }
        }]
      }]
    },
    //确认订单页
    {
      path: '/confirmOrder',
      name: 'confirmOrder',
      component: confirmOrder,
      meta: {
        title: '确认订单',
        requiresAuth: true
      },
      children: [{
        path: 'chooseAddress', //选择地址
        component: address,
        meta: {
          title: '选择地址',
          requiresAuth: true,
          type: 'confirmOrder'
        },
        children: [{
          path: 'addAddress', //添加地址
          component: add,
          meta: {
            title: '添加地址',
            requiresAuth: true,
            type: 'confirmOrder'
          },
          children: [{
            path: 'searchAddress', //搜索地址
            name: 'searchAddress',
            component: addDetail,
            meta: {
              title: '搜索地址',
              requiresAuth: true,
              type: 'confirmOrder'
            }
          }]
        }]
      }, ]
    },
    //登录页
    {
      path: '/login',
      name: 'login',
      component: login,
      meta: {
        title: '登录'
      }
    },
    //个人信息页
    {
      path: '/profile',
      component: profile,
      meta: {
        title: '我的',
        requiresAuth: true,
        keepAlive: true
      },
      children: [{
        path: 'info', //个人信息详情页
        component: info,
        meta: {
          title: '个人信息',
          requiresAuth: true
        },
        children: [{
          path: 'modifyPassword', //修改密码页
          component: modifyPassword,
          meta: {
            title: '修改密码',
            requiresAuth: true
          }
        }, {
          path: 'modifyPayPassword', //修改支付密码页
          component: modifyPayPassword,
          meta: {
            title: '修改支付密码',
            requiresAuth: true
          }
        }, {
          path: 'address',
          component: address, //编辑地址
          meta: {
            title: '编辑地址',
            requiresAuth: true
          },
          children: [{
            path: 'add',
            component: add,
            meta: {
              title: '新增地址',
              requiresAuth: true
            },
            children: [{
              path: 'addDetail',
              name: 'addDetail',
              component: addDetail,
              meta: {
                title: '地图',
                requiresAuth: true
              },
            }]
          }]
        }]
      }, {
        path: 'statistics', //业绩统计
        component: statistics,
        meta: {
          title: '业绩统计',
          requiresAuth: true
        },
        children: [{
            path: 'saleStatistics', //查看全部
            component: saleStatistics,
            meta: {
              title: '销售统计'
            },
            children: [{
              path: 'choseTime', //选择日期
              component: choseTime,
              meta: {
                title: '选择日期'
              }
            }]
          },
          {
            path: 'customerStatistics', //客户统计页
            component: customerStatistics,
            meta: {
              title: '客户统计'
            }
          },
          {
            path: 'warehouseStatistics', //客户统计页
            component: warehouseStatistics,
            meta: {
              title: '仓库统计'
            },
            children: [{
              path: 'choseTime', //选择日期
              component: choseTime,
              meta: {
                title: '选择日期'
              }
            }]
          },
          {
            path: 'goodsStatistics', //商品统计页
            component: goodsStatistics,
            meta: {
              title: '商品统计'
            },
            children: [{
                path: 'choseTime', //选择日期
                component: choseTime,
                meta: {
                  title: '选择日期'
                }
              },
              {
                path: 'cateDetails', //统计详情
                component: cateDetails,
                meta: {
                  title: '统计详情'
                }
              }
            ]
          }
        ]

      }]
    },
    //订单列表页
    {
      path: '/order',
      component: order,
      meta: {
        title: '订单列表',
        requiresAuth: true
      },
      children: [{
        path: 'orderDetail', //订单详情页
        component: orderDetail,
        meta: {
          title: '订单详情',
          requiresAuth: true
        }
      }, ]
    },
    //修改密码页
    {
      path: '/forget',
      component: forget,
      meta: {
        title: '找回密码'
      },
      children: [{
        path: 'confirmPassword', //确认修改密码页
        component: confirmPassword,
        meta: {
          title: '确认修改密码'
        }
      }]
    },
    //采购单详情页
    {
      path: 'inorderDetail',
      component: inorderDetail,
      meta: {
        title: '采购单详情',
        requiresAuth: true
      }
    },
    //门票兑换管理
    {
      path: '/ticketAdministration',
      component: ticketAdministration,
      meta: {
        title: '兑换管理',
        requiresAuth: true
      }
    },
    //验证凭证吗
    {
      path: '/exchangeCode',
      component: exchangeCode,
      meta: {
        title: '兑换验证码',
        requiresAuth: true
      }
    },
    //资产管理
    {
      path: '/balance',
      component: balance,
      meta: {
        title: '资产管理',
        requiresAuth: true
      },
      children: [{
        path: 'detail', //资产明细
        component: balanceDetail,
        meta: {
          title: '资产明细',
          requiresAuth: true
        }
      }, {
        path: 'recharge', //充值
        component: recharge,
        meta: {
          title: '充值',
          requiresAuth: true
        },
        children: [{
          path: 'rechargeSuccess', //充值结果
          component: rechargeSuccess,
          meta: {
            title: '充值结果',
            requiresAuth: true
          },
        }]
      }, ]
    },
    //积分商城页
    {
      path: '/integralMall',
      component: integralMall,
      meta: {
        title: '积分商城',
        requiresAuth: true
      },
      children: [{
        path: 'howGetJiubi', //如何获取久币
        component: howGetJiubi,
        meta: {
          title: '如何获取久币',
          requiresAuth: true
        }
      }],
    },
    //兑换记录
    {
      path: '/conversionRecord',
      component: conversionRecord,
      meta: {
        title: '兑换记录',
        requiresAuth: true
      }
    },
    //久币消费记录
    {
      path: '/integralRecord',
      component: integralRecord,
      meta: {
        title: '久币消费记录',
        requiresAuth: true
      }
    },
    //我的提货券页
    {
      path: '/myCoupons',
      component: myCoupons,
      meta: {
        title: '我的提货券',
        requiresAuth: true
      }
    },
    { //提货券详情页
      path: '/couponsDetail', //提货券详情页
      component: couponsDetail,
      meta: {
        title: '提货券详情',
        requiresAuth: true
      }
    },
    //消息中心
    {
      path: '/myMessages',
      component: myMessages,
      meta: {
        title: '消息中心',
        requiresAuth: true
      },
      children: [{
        path: 'newMechanisms', //新的供应商
        component: newMechanisms,
        meta: {
          title: '新的供应商',
          requiresAuth: true
        }
      }, {
        path: 'receiveVoucher', //收到的礼券
        component: receiveVoucher,
        meta: {
          title: '收到的礼券',
          requiresAuth: true
        }
      }, ]
    },
    //兑换券和门票详情
    {
      path: '/voucherDetail',
      component: voucherDetail,
      meta: {
        title: '门票/兑换券详情',
        requiresAuth: true
      }
    },
    //查看凭证
    {
      path: '/showValidate',
      component: showValidate,
      meta: {
        title: '查看凭证',
        requiresAuth: true
      }
    },
    //领取兑换门票
    {
      path: '/voucherSellers',
      component: voucherSellers,
      meta: {
        title: '领取兑换门票',
        requiresAuth: true
      }
    },
    //我的门票页
    {
      path: '/myAdmissionTicket',
      component: myAdmissionTicket,
      meta: {
        title: '我的门票',
        requiresAuth: true
      }
    }
  ]
}]
